package com.imy.virtual.client.hook.proxies.atm;

import com.imy.virtual.client.hook.base.BinderInvocationProxy;
import com.imy.virtual.client.hook.base.BinderInvocationStub;
import com.imy.virtual.client.hook.base.Inject;
import com.imy.virtual.client.hook.base.LogInvocation;

import mirror.android.app.ActivityTaskManager;
import mirror.android.app.IActivityTaskManager;
import mirror.android.os.ServiceManager;
import mirror.android.util.Singleton;

@LogInvocation(LogInvocation.Condition.ALWAYS)
@Inject(MethodProxies.class)
public class ActivityTaskManagerStub extends BinderInvocationProxy {
  public ActivityTaskManagerStub() {
    super(IActivityTaskManager.Stub.asInterface, "activity_task");
  }

  @Override
  public void inject() throws Throwable {
    Object singleton = ActivityTaskManager.IActivityTaskManagerSingleton.get();
    Singleton.mInstance.set(singleton, getInvocationStub().getProxyInterface());
    BinderInvocationStub hookAMBinder = new BinderInvocationStub(getInvocationStub().getBaseInterface());
    hookAMBinder.copyMethodProxies(getInvocationStub());
    ServiceManager.sCache.get().put("activity_task", hookAMBinder);

  }

  @Override
  public boolean isEnvBad() {
    return ActivityTaskManager.getService.call()!=getInvocationStub().getProxyInterface();

  }
}
